using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using XProject.Entity;
namespace XProject.DAO
{
    class SayingTypeDAO:DBAccess
    {
        #region sql command
        string SELECT_ALL = "select * from SayingType";
        #endregion
        #region field
        string message;
        #endregion
        #region constructor
        public SayingTypeDAO()
        {
            message = "";
        }            
        #endregion
        #region properties
        public string Message
        {
            get { return message; }
        }
        #endregion
        #region methods
        public IList<SayingType> GetAll()
        {
            IList<SayingType> list = new List<SayingType>();
            try
            {
                OleDbCommand command = new OleDbCommand(SELECT_ALL, conn);
                if (Connect())
                {
                    OleDbDataReader dr = command.ExecuteReader();
                    while (dr.Read())
                    {
                        SayingType type = new SayingType();
                        type.TypeID = dr.GetInt32(0);
                        type.TypeName = dr.GetString(1);
                        type.Note = dr.GetString(2);
                        list.Add(type);
                    }
                    Disconnect();
                }
            }
            catch (OleDbException ex) { message = ex.Message; }
            catch (Exception ex) { message = ex.Message; }
            return list;
        }
        #endregion
    }
}
